{
    var arr = [1, 2, 3, 4, 3, 4];
    var arr2 = [...new Set(arr)];
    console.log('--数组去重--', arr2);
}
{
    let a = [1, 2, 3]
    let b = [...a]   // [1, 2, 3]
    let c = [0, ...a]  // [0, 1, 2, 3]
    let d = [0, ...a, 9]  // [0, 1, 2, 3, 9]

    function test(a, b, c) {
        console.log('----记录一下ES6扩展运算符（三点运算符）...的用法----', a, b, c);
    }

    test(...a); // 1 2 3
}
{
    let [x, y, z, t] = [1, 2];
    [y, x, z, t] = [x, y, y, y];
    console.log('----交换两个变量的值--y--', y, '---x--', x, '---z--', z, '---t--', t);
}
{
    let arr = "hellomybo";
    console.log('---获取字符串中的某个字符-----', arr[1]);
}
{
    // ES5的写法
    let a1 = [1, 2, 3].map(function (x) {
        return x * x;
    });
    // ES6 箭头函数写法
    let a2 = [1, 2, 3].map(x => x * x);
    console.log('----------使用箭头函数代替回调函数-------', a1, a2);
}
{
    var arr1 = ['a', 'b'];
    var arr2 = ['c'];
    var arr3 = ['d', 'e'];
    // ES5的合并数组
    arr1.concat(arr2, arr3);
    // [ 'a', 'b', 'c', 'd', 'e' ]
    // ES6的合并数组
    let arr_demo = [...arr1, ...arr2, ...arr3]
    console.log('-----合并数组----', ...arr_demo)
    // [ 'a', 'b', 'c', 'd', 'e' ]
}

{
    let str = "1234567890";
    let str_new = str.split('').reverse().join('')
    let new_str = [...str].reverse().join('')
    console.log('---字符串反转----', str_new)
    console.log('---字符串反转----', new_str)
}
{
    let fil = ['12', '23', '11', '10', '17'].filter(x => x >= 12)
    console.log('---过滤需要的数值----', fil)
    let arr = [1, 2, 3, 4].map(x => x + 2);
    console.log('---获得计算后的数值----', arr)
}
{
    var arr = [1, [[2, 3], 4], [5, 6]];

    var flat = function* (a) {
        var length = a.length;
        for (var i = 0; i < length; i++) {
            var item = a[i];
            console.log('000000',item)
            console.log('11111',typeof item !== 'number')
            if (item !== 'number') {
               let t = yield* flat(item);
               console.log('-----t----',t)
            } else {
                yield item;
                console.log('----item-----', item)
            }
        }
    };
    for (var f of flat(arr)) {
        console.log('-----数组降维 使用generator迭代器-----',f);
    }
}